<?php defined('SYSPATH') or die('No direct script access.');
require ('application/classes/dao/base.php');

class Controller_setm extends Controller {

    public  function  action_set(){
        echo View::factory('manager/setPageProduct')->bind("data",$parm);
    }
    public function action_setProductHead(){
        $parm = get($this->request);
        $result = rpcCall("productpageset.getByList",$parm);

        if($parm['type'] == 1){
            echo View::factory('manager/setProductHead',$result)->bind("data",$result);

        }
        if($parm['type'] == 2){
            echo View::factory('manager/setProductHot',$result)->bind("data",$result);

        }
        if($parm['type'] == 3){
            $parm['type']=4;
            $parm['action']=3;
            //获取第一个产品设置
            $labelPorduct = call("productpageset.getByList",$parm);

            
            $label = rpcCall("label.labellist",$parm);
            echo View::factory('manager/setPageProductByFrist',$result)->bind("data",$result)
            ->set("labelPorduct",$labelPorduct)->set("label",$label)->set("action",3);
        }
        if($parm['type'] == 6){
            $parm['type']=5;
            //获取第一个产品设置
            $labelPorduct = call("productpageset.getByList",$parm);

            
            $label = rpcCall("label.labellist",$parm);
            echo View::factory('manager/setPageProductByFrist',$result)->bind("data",$result)
            ->set("labelPorduct",$labelPorduct)->set("label",$label)->set("action",6);
        }
        if($parm['type'] == 7){
            $parm['type']=8;
            //获取第一个产品设置
            $labelPorduct = call("productpageset.getByList",$parm);

            
            $label = rpcCall("label.labellist",$parm);
            echo View::factory('manager/setPageProductByFrist',$result)->bind("data",$result)
            ->set("labelPorduct",$labelPorduct)->set("label",$label)->set("action",7);
        }
          if($parm['type'] == 8){
            $parm['type']=10;
            //获取第一个产品设置
            $labelPorduct = call("productpageset.getByList",$parm);

            
            $label = rpcCall("label.labellist",$parm);
            echo View::factory('manager/setPageProductByFrist',$result)->bind("data",$result)
            ->set("labelPorduct",$labelPorduct)->set("label",$label)->set("action",8);
        }
          if($parm['type'] == 9){
            $parm['type']=11;
            //获取第一个产品设置
            $labelPorduct = call("productpageset.getByList",$parm);

            
            $label = rpcCall("label.labellist",$parm);
            echo View::factory('manager/setPageProductByFrist',$result)->bind("data",$result)
            ->set("labelPorduct",$labelPorduct)->set("label",$label)->set("action",9);
        }
    }


    public  function  action_update(){
        $parm = post($this->request);
        $type = get($this->request);
        $parm['type']=$type['type'];
        if($type['type'] == 3){
            
            if(!isset($parm['label']) ||count($parm['label'])==0){
                echo "请选择标签不能为空";
                exit;
            }
            $parm['typeother']=4;
             print_r($parm);
            // return;

            $result = rpcCall("productpageset.setByTypeAndHead",$parm);
            echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
   
            return ;
        }
        if($type['type'] == 6){
            
            if(!isset($parm['label']) ||count($parm['label'])==0){
                echo "请选择标签不能为空";
                exit;
            }
            $parm['typeother']=5;
             print_r($parm);
            // return;

            $result = rpcCall("productpageset.setByTypeAndHead",$parm);
            echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
   
            return ;
        }
        if($type['type'] == 7){
            
            if(!isset($parm['label']) ||count($parm['label'])==0){
                echo "请选择标签不能为空";
                exit;
            }
            $parm['typeother']=8;
             print_r($parm);
            // return;

            $result = rpcCall("productpageset.setByTypeAndHead",$parm);
            // echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
   
            return ;
        }
         if($type['type'] == 8){
            
            if(!isset($parm['label']) ||count($parm['label'])==0){
                echo "请选择标签不能为空";
                exit;
            }
            $parm['typeother']=10;
             print_r($parm);
            // return;

            $result = rpcCall("productpageset.setByTypeAndHead",$parm);
            echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
   
            return ;
        }
         if($type['type'] == 9){
            
            if(!isset($parm['label']) ||count($parm['label'])==0){
                echo "请选择标签不能为空";
                exit;
            }
            $parm['typeother']=11;
             print_r($parm);
            // return;

            $result = rpcCall("productpageset.setByTypeAndHead",$parm);
            echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
   
            return ;
        }
        if($type['type'] == 1){
            $parm['desc'] = "";

        }
        $result = rpcCall("productpageset.updateByType",$parm);
         echo "<script>window.location.href='".Url::base()."index.php/setm/setProductHead?type=".$parm['type']."'</script>";
    }

    public function action_setLoginImg(){
//        $parm = get($this->request);
        $parm['type']=22;
        $result = rpcCall("productpageset.getLoginImg",$parm);
//        print_r($result);
        echo View::factory('manager/setLoginImg')->bind("data",$result);
    }

    public function action_setImgUpdate(){
        echo  '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
        $parm = post($this->request);
        print_r($parm);
        if(!isset($parm['pic']) ||$parm['pic']==""){
            echo "图片不能为空";
            exit;
        }
        rpcCall('productpageset.updateLoginImg',$parm);
        echo "<script>window.location.href='".Url::base()."index.php/setm/setLoginImg'</script>";
    }
}